package com.ostrich.a2104gao5.test22

/**
 * @Author : yaotianxue
 * @Time : On 2023/10/17 13:20
 * @Description : Vip
 *
 * 泛型约束
 */
//父类
open class Vip(price:Int) {
}
//子类：必须继承父类的主构造
class TApple(var price:Int):Vip(price)

//泛型约束，只能放Vip或子类
class TFood<T:Vip>(item:T){

}
fun main(){
    val food:TFood<TApple> = TFood(TApple(45566))
}
